<?php

namespace Admin\Controller;
use Admin\Builder\AdminConfigBuilder;

class ConinfController  extends AdminController {
    public function index(){
    	$coninf	=	M('TbConinf');
        $hetong = I('hetong', '', 'text');
        $map['status'] = array('egt', 0);
        $map['cID'] = UID;
        if ($hetong !== '') {
            $map['hetong'] = array('like', '%' . (string)$hetong . '%');
        }
        
        
       /*  $list = $this->lists($coninf, $map);  */
     $list=$coninf->join('duijie_tb_techol on duijie_tb_coninf.cid=duijie_tb_techol.id')
        ->join('duijie_tb_tecach on duijie_tb_coninf.jcid=duijie_tb_tecach.id')
        ->join('duijie_tb_tecdem on duijie_tb_coninf.jqid=duijie_tb_tecdem.id')
        ->select();

     int_to_string($list,array('htstatus'=>array(0=>'双方未确认',1=>'甲方已确认，乙方未确认',2=>'双方已确认',3=>'合同已生效')));              //数字转为字符串
        
        $this->assign('_list', $list);
        $this->display();
    }
    
	public function add(){
		$this->display('edit');
	}
	
	public function edit(){
		$id=I('id');
		$model	=	M('TbConinf');
		/* $data = $model->join('duijie_tb_techol on duijie_tb_coninf.cid=duijie_tb_techol.id')
		->join('duijie_tb_tecach on duijie_tb_coninf.jcid=duijie_tb_tecach.id')
		->join('duijie_tb_tecdem on duijie_tb_coninf.jqid=duijie_tb_tecdem.id')
		->find($id); */
		$data=$model->find($id);
		$this->assign('data', $data);
		$this->display('edit');
	}
	
	public function save(){
		$model	=	M('TbConinf');
		$con	=	$model->create();
		if(empty($con['id'])){
			$con['cID']=UID;
			$model->add($con);
			$this->success("合同添加成功！",U('index'));
		}else {
			$model->save($con);
			$this->success("合同修改成功！",U('index'));
		}
	}
	public function del(){
		$map['id']	=   I('id');	
		$this->delete('TbPatent',$map,array('success' => '专利删除成功！', 'error' => '专利删除失败！'));
	}
// 	public function edit(){
// 		$builder = new AdminConfigBuilder();
// 		$data = $builder->handleConfig();
// 		$builder->keyMultiImage('', '', '');

// 		$builder->display();
// 	}
	
}